package coolq.yaozhenyong.cocApi.custom;
/***
 * COC转义工具
 * @author 936642284
 *
 */
public class CocApiAndCqCustom {
	/***
	 * 查询此村庄加入状态
	 * @param type
	 * @return
	 */
	public static String CocTpe(String type) {
		if(type.equals("inviteOnly")) {
			return "只有批准了才可加入";
		}else if(type.equals("open")) {
			return "任何人可加入";
		}else if(type.equals("closed")) {
			return "不可加入[CQ:emoji,id=128695]";
		}else {
			return type;
		}
	}
	/***
	 * 战争频率
	 * @param warFrequency
	 * @return 
	 */
	public static String CocWarFrequency(String warFrequency) {
		if(warFrequency.equals("always")) {
			return "始终";
		}else if(warFrequency.equals("lessThanOncePerWeek")) {
			return "很少";
		}else if(warFrequency.equals("moreThanOncePerWeek")) {
			return "一周两次";
		}else if(warFrequency.equals("lessThanOncePerWeek")) {
			return "一周一次";
		}else {
			return "未设置";
		}
	}
	/***
	 * 玩家职位
	 * @param role
	 * @return
	 */
	public static String CocRole(String role) {
		if(role.equals("leader")) {
			return "首领";
		}else if(role.equals("coLeader")) {
			return "副首领";
		}else if(role.equals("admin")) {
			return "长老";
		}else if(role.equals("member")){
			return "成员";
		}else {
			return "未知";
		}
		
	}
	/***
	 * 捐收比
	 * @param donations 捐兵
	 * @param donationsReceived 收兵
	 * @return 捐收比
	 */
	public static String DonationsJuanShou(String donations, String donationsReceived) {
		try {
			int a = Integer.valueOf(donations);
			int b = Integer.valueOf(donationsReceived);
			int tmp = a;
		    if(a > b) {
		        tmp = b;
		    }
		    for(int i = tmp; i > 0; i--) {
		        if(a % i == 0 && b % i ==0) {
		        	System.out.println(a + ":" + b + "=" + (a / i) + ":" + (b / i));
		        	return (a / i) + ":" + (b / i);
		        }
		    }
		} catch (Exception e) {
		}
		return "";
	}
	
	/***
	 * 捐收比 超进化
	 * @param donations 捐兵
	 * @param donationsReceived 收兵
	 * @return CQ语言
	 */
	public static String DonationsJuanShouIng(String donations, String donationsReceived) {
		try {
			int juan = Integer.valueOf(donations);
			int shou = Integer.valueOf(donationsReceived);
			double bili = 0.0;
			if(juan>shou) {
				bili = juan / shou;
				if(bili>5) {
					return "[CQ:emoji,id=9989]";
				}
			}else {
				bili = shou / juan;
				if(bili>5) {
					return "[CQ:emoji,id=10060]";
				}
			}
			
		} catch (Exception e) {
		}
		return "";
	}
	/****
	 * 返回部落所属杯段
	 * @param trophies
	 */
	public static String trophies(String trophies) {
		int parseInt = Integer.parseInt(trophies);
		if(parseInt>=5000) {
			return "传奇";
		}else if(parseInt>=4100) {
			return "泰坦";
		}else if(parseInt>=3200) {
			return "冠军";
		}else if(parseInt>=2600) {
			return "水晶";
		}else if(parseInt>=1400) {
			return "金杯";
		}else if(parseInt>=800) {
			return "银杯";
		}else if(parseInt>=400) {
			return "铜杯";
		}else{
			return "无杯";
		}
	}
}
